import { List , Button , Calendar} from 'antd-mobile'
import { PureComponent } from 'react';
import {cform} from 'antdlib'
import {CInput , CForm , FormControl } from 'antdlib/mobile'
import {CCalendar} from '../component/mform';
import { Formatter } from '../util';

@cform()
export default class extends PureComponent {

  options = [
    { label: 1, value: 1 },
  ];

  componentDidMount() {
    this.props.form.setFieldsValue({
      username: '123',
      range:['2018-01-12','2018-01-18']
    });
  }

  handleSubmit = (values) => {
    console.log('values', values);
  };

  rules = {
    username: [{required: true, message: '用户名必须' }],
    username1: [{ required: true, message: '用户名必须' }],
  };

  render() {
    return (
      <CForm rules={this.rules} onSubmit={this.handleSubmit}>
        <List>
          <List.Item>
            <CInput type="money" name="username" label="用户名"/>
            <CInput placeholder='placeholder' name="username" label=""/>
          </List.Item>

          <CCalendar name="range" label="选择日期"  formatter={Formatter}/>

          <List.Item>
            <FormControl onSubmit={this.handleSubmit}>
              <Button type={'primary'}>提交</Button>
            </FormControl>
          </List.Item>
        </List>
      </CForm>
    );
  }

  onConfirm(v) {
    console.log(v , typeof v)
  }
}
